# 课程模块接口封装，核心在于依据接口文档实现接口信息封装，重点关注接口如何被调用

import requests
import config


# 创建接口类
class CourseAPI:
    # 初始化
    def __init__(self):
        self.url_add_course = config.BASE_URL + "/api/clues/course"
        self.url_select_course = config.BASE_URL + "/api/clues/course/list"

    # 课程添加
    def course_add(self, test_data, token):
        return requests.post(url=self.url_add_course, headers={"Authorization": token}, json=test_data)

    # 查询课程列表
    def select_course(self, test_data, token): 
        return requests.get(url=self.url_select_course, params=test_data, headers={"Authorization": token})

    # 课程修改
    def update_course(self, test_data, token):
        return requests.put(url=self.url_add_course, json=test_data, headers={"Authorization": token})

    # 课程删除
    def delete_course(self, course_id, token):
        return requests.delete(url=self.url_add_course + f"/{course_id}", headers={"Authorization": token})
